package test

import scala.io.Source

object helloScala {
  def main(args: Array[String]): Unit = {
    //定义文件路径
   val filename="word.txt"
    //读取文件内容，对每行内容使用正则表达式j'x
    val words=Source.fromFile(filename).getLines().flatMap(_.split("\\W+")).toList
    words.foreach{word=>
      if (isPalindrome(word)){
        println(word)
      }
    }
  }
  def isPalindrome(word: String):Boolean={
    word.equalsIgnoreCase(word.reverse)
  }
}

